// 首页
var util = require("../../utils/util");
Page({
  data: {
    swiperData : [],
    swiperHeight: 330,
    supportImgUrl  : getApp().globalData.STATIC_URL + 'index/cxjs.png',
    menImgUrl   : getApp().globalData.STATIC_URL + 'index/men@2x.png',
    womenImgUrl : getApp().globalData.STATIC_URL + 'index/women@2x.png',
    kidsImgUrl  : getApp().globalData.STATIC_URL + 'index/kids@2x.png'
  },
  onLoad: function(){
      console.log('onLoad');
      var that = this;
      var tableID = getApp().globalData.TABLE_ID_BANNER;
      var objects = { tableID };
      wx.BaaS.getRecordList(objects).then( (res) => {
        // success
        console.log(res);
        that.setData({
          swiperData: res.data.objects
        });
      }, (err) => {
        // err
      });
  },
  onShow: function(){
      console.log("onShow");
  },
  imageLoad : function(e){
    var imageSize = util.imageUtil(e);
    console.log(imageSize);
    this.setData({
      swiperHeight: imageSize.imageHeight
    });
  },
  bannerTap: function(e){
    var link = e.currentTarget.dataset.link;
    console.log(util.generatePageUrl(link));
    wx.navigateTo({
      url: '..' + util.generatePageUrl(link)
    })
  },
  supportTap: function(){
      wx.navigateTo({
        url: '../support/support'
      })
  },
  menTap: function(){
    wx.navigateTo({
      url: '../clothMen/clothMen'
    })
  },
  womenTap: function(){
    wx.navigateTo({
      url: '../clothWomen/clothWomen'
    })
  },
  kidsTap: function(){
    wx.navigateTo({
      url: '../clothKids/clothKids'
    })
  },
  onShareAppMessage: function () {
    return {
      title: '北江纺织丹宁成衣平台',
      path: '/pages/index/index'
    }
  }
})